package miiteen.demo.duty.controller;

import miiteen.common.json.JsonUtil;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.demo.duty.beans.DutyInfo;
import miiteen.demo.duty.service.DutyInfoService;
import miiteen.sys.base.controller.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/demo/duty/dutyInfo")
@CrossOrigin
public class DutyInfoController extends BaseAction {

    @Autowired
    private DutyInfoService dutyInfoService;



    @RequestMapping("/getDutyInfo")
    @ResponseBody
    public ResultMessage<Object> getInstructionInfo(@RequestParam String beginTime, @RequestParam String endTime) {
        Map<String,Object> map=new HashMap<>();

        map.put("beginTime",beginTime);
        map.put("endTime",endTime);

        List<DutyInfo> list=dutyInfoService.findByTime(map);
        if(list.size()>0){
            return ResultMessageTool.Success("查询成功",list);
        }else{
            return ResultMessageTool.Error("查询失败");
        }

    }

}
